Date.prototype.Format = function (format) {
  var o = {
    "M+": this.getMonth() + 1, //month
    "d+": this.getDate(),    //day
    "h+": this.getHours(),   //hour
    "m+": this.getMinutes(), //minute
    "s+": this.getSeconds(), //second
    "q+": Math.floor((this.getMonth() + 3) / 3),  //quarter
    "S": this.getMilliseconds() //millisecond
  }
  if (/(y+)/.test(format)) format = format.replace(RegExp.$1,
    (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  for (var k in o) if (new RegExp("(" + k + ")").test(format))
    format = format.replace(RegExp.$1,
      RegExp.$1.length == 1 ? o[k] :
        ("00" + o[k]).substr(("" + o[k]).length));
  return format;
}

export const time_jz = function(val){
  console.log(val)
  var ctime = new Date();
  if (val == 1) {
    var arr = [];
    var stime = ctime.setHours(0, 0, 0);
    stime = new Date(stime).Format("yyyy-MM-dd hh:mm:ss");
    arr.push(stime)
    var etime = ctime.setHours(23, 59, 59);
    etime = new Date(etime).Format("yyyy-MM-dd hh:mm:ss");
    arr.push(etime)
    return arr

  }
  if (val == 2) {
    var arr = [];
    ctime.setDate(ctime.getDate() - 1);
    var stime = ctime.setHours(0, 0, 0);
    stime = new Date(stime).Format("yyyy-MM-dd hh:mm:ss");
    arr.push(stime)
    var etime = ctime.setHours(23, 59, 59);
    etime = new Date(etime).Format("yyyy-MM-dd hh:mm:ss");
    arr.push(etime)
    return arr
  }
  if (val == 7) {
    var arr = [];
    ctime.setDate(ctime.getDate() - 7);
    var stime = ctime.setHours(0, 0, 0);
    stime = new Date(stime).Format("yyyy-MM-dd hh:mm:ss");
    arr.push(stime)
    var ntime = new Date()
    var etime = ntime.setHours(23, 59, 59);
    etime = new Date(etime).Format("yyyy-MM-dd hh:mm:ss");
    arr.push(etime)
    return arr
  }
  if (val == 30) {
    var arr = [];
    ctime.setDate(ctime.getDate() - 30);
    var stime = ctime.setHours(0, 0, 0);
    stime = new Date(stime).Format("yyyy-MM-dd hh:mm:ss");
    arr.push(stime)
    var ntime = new Date()
    var etime = ntime.setHours(23, 59, 59);
    etime = new Date(etime).Format("yyyy-MM-dd hh:mm:ss");
    arr.push(etime)
    return arr
  }
};